import { createVuePlugin } from 'vite-plugin-vue2'
import { defineConfig } from 'vite'
const path = require('path')
// import path from 'path'

import themePreprocessorPlugin from '@zougt/vite-plugin-theme-preprocessor'

export default defineConfig({
  plugins: [
    createVuePlugin(),
    // 动态切换主题
    themePreprocessorPlugin({
      less: {
        // 各个主题文件的位置
        multipleScopeVars: [
          {
            scopeName: 'theme-default',
            path: path.resolve('src/theme/default.less'),
          },
          {
            scopeName: 'theme-green',
            path: path.resolve('src/theme/green.less'),
          },
          {
            scopeName: 'theme-dark',
            path: path.resolve('src/theme/green.less'),
          },
        ],
      },
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 8888,
    host: '0.0.0.0',
    hot: true,
    cors: true,
    open: false,
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
})
